﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace EquipmentModule.Entity
{
    /// <summary>
    /// 流向仪数据
    /// </summary>
    public class FlowChart
    {
        /// <summary>
        /// 设备Id
        /// </summary>
        public string DeviceId { get; set; }
        /// <summary>
        /// 设备名
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; }
        /// <summary>
        /// 电压
        /// </summary>
        public string BatteryLevel { get; set; }
        /// <summary>
        /// 温度
        /// </summary>
        public string Temperature { get; set; }
        /// <summary>
        /// 信号强度
        /// </summary>
        public string Rssi { get; set; }
        /// <summary>
        /// 04 开关信号 05 心跳信号
        /// </summary>
        public string DataType { get; set; }
        /// <summary>
        /// 井盖一体化传感器:74
        /// </summary>
        public string DeviceType { get; set; }
        /// <summary>
        /// 井盖开关状态 0-关闭、1-打开（正向）
        /// </summary>
        public string CoverState { get; set; }
        /// <summary>
        /// 液位开关状态 0-无水、1-有水（逆向）
        /// </summary>
        public string LiquidState { get; set; }

        /// <summary>
        /// 流向
        /// </summary>
        public string Direction
        {
            get
            {
                if (this.CoverState == "1" && this.LiquidState == "0")
                {
                    return "正向";
                }
                else if (this.CoverState == "0" && this.LiquidState == "1")
                {
                    return "逆向";
                }
                else if(this.CoverState == "1" && this.LiquidState == "1")
                {
                    return "异常";
                }
                return "关闭";
            }
        }

        public override string ToString()
        {
            string direction = "";
            if (this.CoverState=="1" && this.LiquidState=="0")
            {
                 direction = "正向";
            }
            else if (this.CoverState == "0" && this.LiquidState == "1")
            {
                direction = "逆向";
            }
            else if (this.CoverState == "1" && this.LiquidState == "1")
            {
                direction = "异常";
            }
            else
            {
                direction = "关闭";
            }
            return $"设备Id:{this.DeviceId},设备名称：{this.Name},信号类型：{this.DataType},电压：{this.BatteryLevel},温度：{this.Temperature},流向:{direction}";
        }

    }
}




//开关数据
//{
// "deviceId": "1091000199",
// "name": "NB-IoT 窨井一体化测控终端(BJ-S109)1091000199",
// "updateTime": "2018-07-11 09:59:00",
// "batteryLevel": "3.6",
// "temperature": "31",
// "rssi": "5",
// "dataType": "04",
// "deviceType": "74",
// "coverState": "1",
//"liquidState": "1"
//}

//心跳数据
//{
// "deviceId": "1091000199",
// "name": "NB-IoT 窨井一体化测控终端(BJ-S109)1091000199",
// "updateTime": "2018-07-11 09:59:00",
// "batteryLevel": "3.6",
// "temperature": "31",
// "rssi": "5",
// "dataType": "05",
//"deviceType": "74",
//"coverState": "1",
//"liquidState": "1"
//}